// pages/doctor-course-weChatpay/doctor-course-weChatpay.js
const app =getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgBase: app.globalData.imgUrl,          // 线上图片
    localImg: app.globalData.staticimgUrl,  // 本地图片
    orderid: '',
    beautyCoin: '',
    totalPrice:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      orderid: options.orderid,
      beautyCoin: options.beautyCoin,
      totalPrice: options.totalPrice
    })
  },
  //传订单id
  pay() {
    let param = {
      orderid: this.data.orderid,
      payType: 2
    };
    app.request({
      url: "shopp/payment/requestPayment",
      data: param,
      success: function (res) {
        wx.requestPayment({
          'timeStamp': res.data.timeStamp,
          'nonceStr': res.data.nonceStr,
          'package': res.data.package,
          'signType': res.data.signType,
          'paySign': res.data.paySign,
          'success': function (res) {
            console.log(res)
            if (res.errMsg == "requestPayment:ok") {
              wx.navigateTo({
                url: 'pages/doctor-train/doctor-train'
              })
            }
          },
          'fail': function (res) { },
          'complete': function (res) { }
        })
      },
      fail: function (res) { }
    });
  },

})